package com.jacky.androidutils.test;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

import com.jacky.androidutils.database.dao.base.DAOHelper;

public class DBHelper extends DAOHelper {
	private static final String NAME = "cl.db";
	private static final int CURRENT_VERSION = 3;
	private static final int HISTORY_VERSION = 2;
	private static final int START_VERSION = 1;

	public DBHelper(Context context) {
		super(context, NAME, null, CURRENT_VERSION);
		// TODO Auto-generated constructor stub
	}

	public static final String TABLE_ID = "_id";// 新闻主键

	public static final String TABLE_NEWS_NAME = "news";// 新闻表名
	public static final String TABLE_NEWS_TITLE = "title";// 新闻标题
	public static final String TABLE_NEWS_SUMMARY = "summary";// 新闻摘要

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL("CREATE TABLE " + TABLE_NEWS_NAME + " (" + TABLE_ID
				+ " integer primary key autoincrement, " + TABLE_NEWS_TITLE
				+ " varchar(50), " + TABLE_NEWS_SUMMARY + " VARCHAR(200))");
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
		//跟新
		//数据库版本管理：1.0（一张表）   2.0（两张表）
//		db.execSQL("CREATE TABLE " + "book" + " (" + TABLE_ID
//				+ " integer primary key autoincrement, " + TABLE_NEWS_TITLE
//				+ " varchar(50), " + TABLE_NEWS_SUMMARY + " VARCHAR(200))");

		/*
		 * 模拟两用户
		 * 老用户：1.0（没问题）
		 * 新用户：（出问题）
		 */
		switch (oldVersion) {
			case START_VERSION:

				break;
			case HISTORY_VERSION:

				break;
			case CURRENT_VERSION:

				break;

			default:
				break;
		}
	}

}
